<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\modules\home\models\MhBanner */

$this->title = '详情';
$this->params['breadcrumbs'][] = ['label' => '轮播列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mh-banner-view">

    <p>
        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
        <?= Html::a('图片上传', ['upload', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            [
                'format' => 'raw',
                'attribute' => 'cid',
                'value' => function($model) {
                    if($model->cid == 1){
                        return '<span class="btn btn-xs btn-success">首页轮播</span>';
                    }else{
                        return '<span class="btn btn-xs btn-success">手机端轮播</span>';
                    }
                },
            ],
            'title',
            'subtitle',
            [
                'format' => 'raw',
                'attribute' => 'img_path',
                'value' => function($model) {
                    if($model->img_path){
                        $per_url = Yii::$app->params['imgurl'];
                        return '<img src="'.$per_url . $model->img_path.'" style="height:100px;">';
                    }else{
                        return '';
                    }
                },
            ],
            'url:url',
            'sort',
            [
                'format' => 'raw',
                'attribute' => 'create_time',
                'value' => function($model) {
                    return date('Y-m-d H:i:s', $model->create_time);
                },
            ],
        ],
    ]) ?>

</div>
